package main

import "learngo/Slices/reading_text"

/*
	切片底层是数组实现
*/
func main() {
	// notes := make([]string, 7)
	// fmt.Println(len(notes))

	//基本使用
	/* letters := []string{"a", "b", "c"}
	for _, letter := range letters {
		fmt.Println(letter)
	} */

	//切片指向数组的子集
	/* underlyingArray := [5]string{"a", "b", "c", "d", "e"}
	i, j := 1, 4
	slice := underlyingArray[i:j]
	fmt.Println(slice) */

	//使用append函数
	/* s1 := []string{"s1", "s2"}
	s2 := append(s1, "s2", "s2")
	s3 := append(s2, "s3", "s3")
	s4 := append(s3, "s4", "s4")
	fmt.Println(s1, s2, s3, s4)

	s4[0] = "xx"
	fmt.Println(s1, s2, s3, s4) */

	reading_text.AverageNum()

	//使用可变长参数函数
	/* 	fmt.Println(variadic_func.Maximum(71.8, 56.2, 89.5))
	   	fmt.Println(variadic_func.Maximum(90.7, 89.7, 98.5, 92.3)) */

	//向可变长参数函数传递一个切片
	/* 	arguments := os.Args[1:]
	   	var numbers []float64
	   	for _, argument := range arguments {
	   		number, err := strconv.ParseFloat(argument, 64)
	   		if err != nil {
	   			log.Fatal(err)
	   		}
	   		numbers = append(numbers, number)
	   	}

	   	fmt.Printf("Average: %0.2f\n", variadic_func.Average(numbers...)) */
}
